<extend name="template/base_top" />
<block name="area_header">
<script  src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
</block>
<block name="area_body">


    <div class="am-cf cart-panel">
        <div class="withdrawals-panel">
            <div class="am-cf qrcode-title-panel">
                <div class="qrcode-face"><img src="{$avatar}" class="am-img-responsive" /></div>
                <div class="qrcode-myinfo">
                    <p>我是 {$nickname}</p>
                    <p>我为藏味优品代言</p>
                </div>
            </div>
            <hr data-am-widget="divider" style="" class="am-divider am-divider-default"/>
            <p class="am-text-center">我的推广二维码</p>
            <p class="am-text-center"><img src="{$code_imgurl}" class="qrcode-qrcode" /></p>
            <hr data-am-widget="divider" style="" class="am-divider am-divider-default"/>

            <form class="am-form">
                <div class="am-form-group">
                    <p class="am-text-right"><a class="am-btn am-btn-danger am-show-sm-only am-btn-sm am-radius" id="onMenuShareTimeline" >立即分享</a></p>
                </div>
            </form>
        </div>
    </div>
    <script type="text/javascript">
        {$config}
        wx.ready(function () {
            // 2.2 监听“分享到朋友圈”按钮点击、自定义分享内容及分享结果接口
            document.querySelector('#onMenuShareTimeline').onclick = function () {

                wx.onMenuShareTimeline({
                    title: '藏味优品',
                    link: 'http://cangwei.itboye.com/index.php/Home/index/index',
                    imgUrl: "{$code_imgurl}",
                    trigger: function (res) {
                        $('.am-modal-alert .am-modal-bd').text('感谢你来到朋友圈分享');
                        $('#my-alert').modal();
                    },
                    success: function (res) {
                        $('.am-modal-alert .am-modal-bd').text('已经分享成功');
                        $('#my-alert').modal();
                    },
                    cancel: function (res) {
                        $('.am-modal-alert .am-modal-bd').text('您已经取消了分享');
                        $('#my-alert').modal();
                    },
                    fail: function (res) {
                        alert(JSON.stringify(res));
                    }
                });
                $('.am-modal-alert .am-modal-bd').text('分享已经注册成功了您可以在微信工具栏上进行分享');
                $('#my-alert').modal();
            };
        });
        wx.error(function(res){
            console.log(res);
        });
    </script>

    <!--弹出分享注册已经成功-->
    <div class="am-modal am-modal-alert" tabindex="-1" id="my-alert">
        <div class="am-modal-dialog">
            <div class="am-modal-hd">系统提醒</div>
            <div class="am-modal-bd">
                分享已经注册成功了您可以在微信工具栏上进行分享
            </div>
            <div class="am-modal-footer">
                <span class="am-modal-btn">确定</span>
            </div>
        </div>
    </div>

</block>